/**   
* @Title: UserController.java
* @Package com.an.nopro.controller
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com   
* @date 2017年8月6日 下午8:43:41
* @version V1.0   
*/


package com.an.nopro.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.an.nopro.entity.UserEntity;
import com.an.nopro.mapper.spring.UserMapper2;

/**
* @ClassName: UserController
* @Description: TODO(这里用一句话描述这个类的作用)
* @author antch,861710865@qq.com
* @date 2017年8月6日 下午8:43:41
* 
*/

@RestController
public class UserController {

	@Autowired
	public UserMapper2 userMapper;

	@RequestMapping("/getUsers")
	public List<UserEntity> getUsers(){
		return userMapper.getAll();
	}
	
	@RequestMapping("/getUser")
	public UserEntity getUser(Long id) {
		System.out.println("can熟：" + id);
		return userMapper.getOne(id);
	}
	
	@RequestMapping("/add")
    public void save(UserEntity user) {
    	userMapper.insert(user);
    }
    
    @RequestMapping(value="update")
    public void update(UserEntity user) {
    	userMapper.update(user);
    }
    
    @RequestMapping(value="/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
    	userMapper.delete(id);
    }

}
